﻿@model  IList<ProductModel>
@{
    ViewBag.Title = "产品管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="path mb15">
    当前位置:<span>首页 &gt; </span><span>商品管理 &gt; </span>
</div>
<form id="GetForm" name="GetForm" method="get" onclick="return checkQuery()">
<div>
    <table class="tb-search mb10">
            <tr>
                <td>
                    商品名称：
                </td>
                <td class="box">
                    <input name="txtTrueName" value="@ViewBag.TrueName" class="input-style-d" />
                </td>
                <td class="box">
                    <input type="submit" value="搜索" class="i-btn1" />
                    &nbsp;
                    <input type="button" value="新增" class="i-btn1" onclick="location='/Product/Edit';" />
                </td>
            </tr>
        </table>
</div>
<div>
    <table class="tb-data">
        <thead>
            <tr>
                <th>
                    编号
                </th>
                <th>
                    名称
                </th>
                <th>
                    访问次数
                </th>
                <th>
                    评论次数
                </th>
               <th>
                    Taoke
                </th>
                <th>
                    创建时间
                </th>
                <th>
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
            @if (Model != null)
            {

                foreach (var item in Model)
                { 
                <tr>
                    <td style="width: 5%">
                        @item.ProductID
                    </td>
                    <td style="width: 40%">
                        @item.Title
                    </td>
                    <td style="width: 5%">
                        @item.Visits
                    </td>
                    <td style="width: 5%">
                        @item.Comments
                    </td>
                    <td style="width: 5%">
                        @item.TaoKe
                    </td>
                    <td style="width: 8%">
                        @item.CreateTime
                    </td>
                    <td style="width: 8%">
                        <a href="/Product/Edit?ID=@(item.ProductID)" name="edit">编辑</a>&nbsp;&nbsp;
                        <a href="/AliMaMa/TaoKe?ID=@(item.ProductID)" name="edit">淘客</a>&nbsp;&nbsp;
                        <a href="javascript:void(0);" onclick="Disable('@(item.ProductID)')" name="delete">删除</a>
                    </td>
                </tr>
                }
            }
        </tbody>
    </table>
    <!-- 分页插件  -->
    <div id="pager" class="aR mt10">
    </div>
</div>
@*@if (Model != null)
{
    var pagerModel = @ViewBag.PagerModel as PagerModel;
    pagerModel.GetForm = "GetForm";
    Html.RenderPartial("PagerExControl", pagerModel);
}
else
{
    <span>没有找到您需要的搜索结果,请检查您的搜索条件!</span>
}*@
</form>
<script type="text/javascript">
	function checkQuery() {

		var t = 0;
		if ($('#txtBeginDate').val() != "") t++;
		if ($('#txtEndDate').val() != "") t++;

		if (t == 1) {
			alert("请将查询日期输入完整");
			return false;
		}
		return true;
	}

	function Detail(id) {
		OpenPop({
			page: '/Account/Detail?accountID=' + id,
			title: '查看账号',
			width: 450,
			height: 550
		});
	}

	function Edit(id) {
		OpenPop({
			page: '/Account/Edit?accountID=' + id,
			title: '选择关联账号',
			width: 450,
			height: 550
		});

	}

	(function () {
		//日期
		var dates = $('#txtBeginDate, #txtEndDate').datepicker({
			onSelect: function (selectedDate) {
				var option = this.id == "txtBeginDate" ? "minDate" : "maxDate",
				            instance = $(this).data("datepicker"),
				            date = $.datepicker.parseDate(
					            instance.settings.dateFormat ||
					            $.datepicker._defaults.dateFormat,
					            selectedDate, instance.settings
				            );
				dates.not(this).datepicker("option", option, date);
			}
		});
	})();

	// 删除即禁用
	function Disable(id) {
		OpenConfirm("提示", "您确定要将这条数据删除吗?", function () {

			$.ajax({
				url: "/account/disable?accountID=" + id,
				type: "POST",
				success: function (data) {
					if (data.status == "error" || data.status == "warning") {
						alert(data.msg);
						return false;
					}
					alert(data.msg);
					location = location;
				}
			})
		});
	}

	function Allow(id) {
		$("#accountID").val(id)
		GetForm.action = "/Account/Allow";
		GetForm.submit();
	}

	// 2012-4-25 陈炎明
	// 设置权限
	function SetRole(id) {
		OpenPop({
			page: '/AccountPermission/Edit?accountID=' + id,
			title: '设置权限',
			width: 950,
			height: 500
		});
	}        
</script>
